package dbTest;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import java.sql.CallableStatement;

/**
 * 如何调用存储过程
 * @author admin
 *
 */
@SuppressWarnings("all")
public class JdbcTest2 {

	public static void main(String[] args) {
		
	}
	private static void executCall(String name) throws SQLException {
		Connection connection = null;
		CallableStatement cStatement = null;
		ResultSet resultSet = null;
		try {
			//1、加载驱动
			Class.forName("oracle.jdbc.driver.OracleDriver");
			String url = "jdbc:oracle:thin:@127.0.0.1:1521:orcl";
			//连接数据库
			connection = DriverManager.getConnection(url, "guanym", "123456");
			String sql  = "{call test(?,?)}";
			cStatement = connection.prepareCall(sql);
			resultSet = cStatement.executeQuery();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			if(connection!=null) {
				connection.close();
			}
			if(resultSet!=null) {
				resultSet.close();
			}
		}
	}
}
